package com.example.a22310.myapplication.ViewModel.Master;

import android.support.v4.app.FragmentActivity;
import android.support.v7.widget.LinearLayoutManager;

import com.example.a22310.myapplication.Adapter.MvvmAdapter;
import com.example.a22310.myapplication.Beans.Coach;
import com.example.a22310.myapplication.Listener.ClubListener;
import com.example.a22310.myapplication.Model.ClubModel;
import com.example.a22310.myapplication.databinding.FragmentMasterBinding;

import java.util.List;

public class MasterViewModel implements ClubListener<Coach> {
    private FragmentMasterBinding binding;
    private FragmentActivity activity;



    public MasterViewModel(FragmentActivity activity, FragmentMasterBinding binding, int club_id){
        this.activity = activity;
        this.binding = binding;
        binding.setMaster(this);
        ClubModel clubModel=new ClubModel();
        clubModel.coachList(club_id,MasterViewModel.this);
    }

    @Override
    public void onSuccess(Coach coach) {
        if(coach.getCode()!=404){
            List<Coach.ClubcoachlistBean> clubcoachlistBeen =  coach.getClubcoachlist();
            binding.recyclerViewActivity.setLayoutManager(
                    new LinearLayoutManager(activity));
            MvvmAdapter adapter = new MvvmAdapter(activity, R.layout.cardview_coach,
                    clubcoachlistBeen, BR.coach);
            binding.recyclerViewActivity.setAdapter(adapter);

        }

    }

    @Override
    public void onFailure() {
    }
}

